import Vue from 'vue'
import Vuex from 'vuex'
import getters from "./getters"
import permission from "./modules/permission"
import user from "./modules/user"
Vue.use(Vuex)

// 加载modules下所有模块
/*const modulesFiles = require.context('./modules', true, /\.js$/)
const modules = modulesFiles.keys().reduce((modules, modulePath) => {
    // set './app.js' => 'app'
    const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
    const value = modulesFiles(modulePath)
    modules[moduleName] = value.default
    return modules
}, {})*/

const store = new Vuex.Store({
    // modules,
    modules: {
        permission,
        user,
    },
    getters,
})

export default store






// 创建 store 实例
/*
export default new Vuex.Store({
    actions,
    getters,
    state,
    mutations
})
*/



// 应用初始状态
/*
const state = {
    count: 10,
    // token: getToken(),
    // name: '',
    // avatar: '',
    // introduction: '',
    // roles: []
}

// 定义所需的 mutations
const mutations = {
    INCREMENT(state) {
        state.count++
    },
    DECREMENT(state) {
        state.count--
    },

}
*/
